#include "network_settings.h"

NetworkSettings::NetworkSettings(QWidget* parent) :
	QDialog(parent),
	m_lanManager(new LanManager(this))
{
	ui.setupUi(this);

	// disable widgets
	this->setWindowFlags(this->windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
	ui.etOutput->setTextInteractionFlags(Qt::NoTextInteraction);

	// establish connection
	connect(ui.bnConnect, &QPushButton::clicked, m_lanManager, &LanManager::startConnection);

	connect(m_lanManager, &LanManager::log, ui.etOutput, &QTextEdit::append);
	connect(m_lanManager->getDiscoverClient(), &DiscoverClient::log, ui.etOutput, &QTextEdit::append);

	connect(m_lanManager, &LanManager::interfaceReady, this, &NetworkSettings::interfaceReadySlot);
}

void NetworkSettings::interfaceReadySlot(QObject* net)
{
	emit interfaceReady(net);
}